package com.example.erp.mapper.permission;

import com.example.erp.dto.permissionDTO.UserDTO;
import com.example.erp.pojo.permission.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserMapper {
    List<User> list(UserDTO userDTO);
    Integer count(UserDTO userDTO);

    @Select("SELECT * FROM erp_users WHERE id = #{id}")
    User getById(Long id);

    @Select("SELECT * FROM erp_users WHERE username = #{username}")
    User getByName(String username);

    @Select("SELECT * FROM erp_users WHERE  id != #{id} and username = #{username}")
    User getByIdName(@Param("id") Long id,@Param("username")  String username);

    @Select("SELECT * FROM erp_users WHERE avatar LIKE CONCAT('%',#{image,jdbcType=VARCHAR},'%')")
    List<User> getByAvatar(String image);

    Integer add(User user);

    Integer edit(User user);

    Integer remove(List<Long> ids);
}
